Skip to main content

All Questions

Tagged with
6votes
1answer
352views

A straightforward method for computing the Binomial probability mass function

I've been writing up code to test an alternate way of calculating the Binomial probability mass function. The Binomial random variable is the number of heads out of N coin tosses with coins that have ...
combo's user avatar
3votes
1answer
257views

Iterative version of a permutations algorithm

For learning purposes, I've written an iterative version of a recursive algorithm for generating the set of permutations for a given set of unique integers. Can I make any improvements to increase ...
yorztif's user avatar
4votes
1answer
106views

Determining if two packs are permutations of each other during compile-time

Often we need to find out if two tuples, or two packs in general, are the same as each other up to permutation. If there are no repeat types, then implementing ...
prestokeys's user avatar
3votes
1answer
682views

Efficiently Generate Subset of all Permutations or Combinations with and without Repetition (C++)

Suppose I want to write some functions which return the vector containing a vector representing all permutations or combinations with or without repetition (dependent on the function) of a subset of a ...
Joe Ford's user avatar
1vote
0answers
680views

Generating combinations from two joined vectors

I have the following code to generate all combinations from two joined vectors. I have some restrictions: Exclude combinations if all members have the same "d" value Exclude combinations if several ...
skualito's user avatar
0votes
1answer
2kviews

All permutations of integer vector

I have spent a decent amount of (waaay too much) time trying to write the below function and get my head around recursion. The aim was to return all permutations of an int vector (assuming no ...
laker93's user avatar
4votes
1answer
367views

Generating vertices of the rectified hypercube

The following piece of code generates the vertices of the rectified hypercube in arbitrary dimensions. The 3D case of the rectified hypercube is a cuboctahedron with 12 vertices (±1,±1,0), (±1,0,±1), (...
plasmacel's user avatar
3votes
1answer
2kviews

Find all distinct combinations of letters in a string

I've been preparing for interviews and picking up modern C++. A recent prep question I did was to find all combinations (or distinct subsets) of letters from a string. E.g. ...
Adam Martin's user avatar
15votes
1answer
376views

Permuting a typelist

Given a typelist, return a typelist of all the permutations of it. For example: ...
Barry's user avatar
  • 18.5k
5votes
2answers
607views

Linear cryptanalysis of a substitution permutation network

I was translating a script I had that would automate linear cryptanalysis of SP networks from Python to C++. For those who aren't familiar with cryptography, linear cryptanalysis involves finding ...
user avatar
4votes
1answer
2kviews

Necklace counting problem-with consecutive prime constraint

This is codeEval challenge to count the number of chains possible to make with beads holding numbers. Constraint is sum of the consecutive beads of chain should be a prime number. The standard ...
Steephen's user avatar
3votes
2answers
264views

Printing all the permutations of a string in alphabetical order-ver1.1

I adapted most of the suggestions from answers for my previous question Printing all the permutations of a string in alphabetical order to rewrote my solution again. Please let me know any more ...
Steephen's user avatar
2votes
4answers
454views

Printing all the permutations of a string in alphabetical order

It is a code eval challenge question https://www.codeeval.com/open_challenges/14/. My answer was accepted, and I modified my code again to improve it. Please let me know is it possible to improve it ...
Steephen's user avatar
9votes
2answers
2kviews

Generating all permutations of a template pack

AllPermutedPacks<Pack<Types...>>::type is to be the pack of packs consisting of all permutations of Types.... For ...
prestokeys's user avatar
4votes
3answers
190views

Another permutator

This is a solution to this problem. The problem statement: write a program to display all possible permutations of a given input string--if the string contains duplicate characters, you may have ...
11684's user avatar

153050per page
close